.TH std::ranges::take_view::size 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::ranges::take_view::size \- std::ranges::take_view::size

.SH Synopsis
   constexpr auto size() requires ranges::sized_range<V>;             \fB(1)\fP \fI(since C++20)\fP
   constexpr auto size() const requires ranges::sized_range<const V>; \fB(2)\fP \fI(since C++20)\fP

   Returns the number of elements, which is the smaller of the count passed to the
   constructor and the size of the underlying view.

   Let base_ be the underlying view, count_ be the number passed to the constructor (0
   if default constructed). Equivalent to

 auto n = ranges::size(base_);
 return ranges::min(n, static_cast<decltype(n)>(count_));

.SH Parameters

   \fI(none)\fP

.SH Return value

   The number of elements.

.SH Example


// Run this code

 #include <iostream>
 #include <ranges>

 int main()
 {
     constexpr int arr[]{1, 2, 3};

     for (int i = 0; i != 6; ++i)
     {
         const auto tv = std::ranges::take_view{arr, i};
         std::cout << tv.size() << ' ';
     }
     std::cout << '\\n';
 }

.SH Output:

 0 1 2 3 3 3

.SH See also

   ranges::size  returns an integer equal to the size of a range
   (C++20)       (customization point object)
   ranges::ssize returns a signed integer equal to the size of a range
   (C++20)       (customization point object)
